package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.toyhouse.config.ToyHouseConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.toyhouse.ToyHouseMgr;

import java.util.ArrayList;
import java.util.List;

public class ToyHouseRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        ToyHouseConfig config = ToyHouseMgr.getConfig();
        if (config != null) {
            ActivityInfo activityInfo = config.getActivityInfo();
            List<String> paramList = new ArrayList<>();
            long recycleTime = activityInfo.getEndTime() * 1000L + 600 * 1000;

            paramList.add(String.valueOf(config.getEnergyId()));
            paramList.add(String.valueOf(config.getScoreId()));
            paramList.add("1");
            paramList.add(activityInfo.getActivityName());
            ActivityItemRecycleMgr.addRecycleItemData(config.getEnergyId(), activityType, 1, recycleTime, paramList);
        }
    }

    @Override
    public boolean isActivityRunning() {
        ToyHouseConfig config = ToyHouseMgr.getConfig();
        return config != null && ActivityMgr.activityInTime(config.getActivityInfo());
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.ToyHouse.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        item2Score(userId, data);
    }
}
